﻿using FinalProject.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace FinalProject.Controllers
{
    public class SongController : Controller
    {
        //
        // GET: /Song/
        SongContext db = new SongContext();
            
        public ActionResult Index()
        {
            try
            {
                var songs = db.Songs.ToList();

                return View(songs);
            }
            catch (Exception e)
            {
                return View(e.ToString());
            }
        }

        //
        // GET: /Song/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Song/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Song/Create

        [HttpPost]
        public ActionResult Create(Song song)
        {
           
            try
            {
                // TODO: Add insert logic here
                db.Songs.Add(song);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Song/Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Song/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Song/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Song/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
